package com.zzh.bc.db.converter;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Date;
import com.zzh.bc.db.ColumnDbType;
/**
 * @Date: 2021/5/24 13:41
 * @Email: zzh_hz@126.com
 * @QQ: 1299234582
 * @Author: zzh
 * @Description: 类型
 */
public class DateColumnConverter implements ColumnConverter<Date> {
    @Override
    public Date getFieldValue(final ResultSet cursor, int index) throws SQLException {
        return new Date(cursor.getLong(index));
    }

    @Override
    public Object fieldValue2DbValue(Date fieldValue) {
        if (fieldValue == null) return null;
        return fieldValue.getTime();
    }

    @Override
    public ColumnDbType getColumnDbType() {
        return ColumnDbType.INTEGER;
    }
}
